package acwing.数学.约数;

import java.util.*;

/**
 * 试除法求约数
 *
 * @author yang
 * @date 2022/1/15
 */
public class 试除法求约数 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            int a = sc.nextInt();
            check(a);
        }
    }

    private static void check(int n) {
        List<Integer> list = new ArrayList<>();
        for (int i = 1; i <= n / i; i++) {
            if (n % i == 0) {
                list.add(i);
                if (n / i != i) list.add(n / i);
            }
        }
        Collections.sort(list, (o1,o2)->o1-o2);
        for (int x : list)
            System.out.print(x + " ");
        System.out.println();
    }

}
